<style scoped>
.wraper {
    padding: 0 30px;
}

.search {
    padding-bottom: 20px;
}

.search span {
    color: #68777c;
    font-weight: bold;
    padding-right: 18px;
}

.search button {
    background-color: #00a8f7;
    color: #fff;
    margin-left: 8px;
}

.top {
    margin-bottom: 20px;
    border-top: 1px dashed #cccccc;
}



.wraper .headline {
    position: relative;
    font-size: 12px;
    color: #303134;
    font-weight: bold;
    margin: 10px 0;
    line-height: 32px;
    height: 32px;
}

.wraper .add-agent {
    position: absolute;
    top: 0px;
    right: 30px;
    background-color: #348bf2;
    color: #fff;
}

.iconfont {
    font-size: 14px;
}

.red-font {
    color: #ff1f1f;
}

/* 分页 start */

.page {
    margin: 20px 0;
}
.ivu-page {
    padding-bottom: 150px;
} 

/* 分页 end */


</style>

<template>
    <div class="employee-manage">
        <product-title></product-title>
        <div class="wraper">
            <div class="search">
                <span>快速搜索</span>
                <Input v-model="searchForm.name" placeholder="请输入员工姓名" style="width: 140px"></Input>
                <Select v-model="searchForm.status" style="width: 140px" placeholder='请选择状态'>
                    <Option value="0" >全部</Option>
                    <Option value="2" >已认证</Option>
                    <Option value="4" >驳回</Option>
                </Select>
                <Button @click='search'>查询</Button>
            </div>
            <div class="detail">
                
                <div class="clearfix">
                    <Table border :columns="columns_validate" :data="data_validate"></Table>
                    <Row class="page fr">
                        <Col span="24">
                            <Page :total="validateTotal" show-total show-sizer @on-change="pageChange" @on-page-size-change="pageSizeChange"></Page>
                        </Col>
                    </Row>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import productTitle from '../../components/productTitle'
import {  getListRecord } from '../../api/validate'

export default {
    data() {

        return {
            checkModal:false,
            closeable: false,
            loading: true,
            page: 1,
            pagesize: 10,
            searchForm: {
                status: '',
            }, 
            showAddModal: false,
            validateTotal: 0,
            columns_validate: [               
                {
                    title: '姓名',
                    key: 'name',
                    align: 'center',
                },
                {
                    title: '身份证号',
                    key: 'id_number',
                    align: 'center',
                },
                {
                    title: '开户行',
                    key: 'bank_name',
                    align: 'center',
                },
                {
                    title: '银行卡号',
                    key: 'card_num',
                    align: 'center',
                },
                {
                    title: '资格证号',
                    key: 'certificate_no',
                    align: 'center',
                },
                {
                    title: '状态',
                    key: 'status',
                    align: 'center',
                    render: (h, params) => {
                        
                        switch(parseInt(params.row.status)){
                            case 1:
                                return '未认证'
                                break;
                            case 2:
                                return '已认证'
                                break;
                            case 3:
                                return '认证中'
                                break;
                            case 4:
                                return '驳回'
                                break;
                        }

                    }
                },
                {
                    title: '操作',
                    key: 'action',
                    align: 'center',
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.toDetail(params.row.id)
                                    }
                                }
                            }, '详情'),
                        ]);
                    }
                },
            ],
            data_validate: [

            ],
            ruleValidate: {
                name: [
                    { required: true, message: '姓名不能为空', trigger: 'blur' }
                ],
                job_num: [
                    { required: true, message: '员工编号不能为空', trigger: 'blur' },
                ],
                rank: [
                    { required: true, message: '请选择级别', trigger: 'blur,change' }
                ],
                login_name: [
                    { required: true, message: '登录名不能为空', trigger: 'blur' },
                ],
            },
        }
    },
    components: {
        productTitle
    },
    created() {

        this.getList()
    },
    methods: {

        // 搜索
        search() {
            this.page = 1
            this.getList()           
        },
        // 获取员工列表
        getList() {
            let _params = {
                'name':this.searchForm.name,
                'p': this.page,
                'pagesize': this.pagesize,
                'status': this.searchForm.status,
            }
            new Promise((resolve, reject) => {
                getListRecord(_params).then(response => {
                    console.log(response.data);
                    if (response.data.err == 0) {
                        this.data_validate = response.data.data.list;
                        this.validateTotal = response.data.data.total;
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },

        // 页码改变
        pageChange(page) {
            this.page = page
            this.getList()
        },
        // 每页条数改变
        pageSizeChange(pagesize) {
            this.pagesize = pagesize
            this.getList();
        },
        toDetail(id){
            this.$router.push({name:'certification_hdetail',params:{id:id}})
        }
    }
}
</script>
